#include "Ex-3-Func.h"

#define PRODUCTION_NUMS 10


/* 
    G = (T,N,P,S)
    eg: 
    T = { a, b, c, d }
    N = { A, S }
    P = { A->a|b, S->Acd }
    S = { S }

    computer data presentation

    CharacterSet:{
        data: {
            S, A, a, b, c, d
        @id:0, 1, 2, 3, 4, 5
        },
        nonTerminalNums: 2
        terminalNums: 4
    } 

    Productions: [
        {
            nonterminalId: A
            sets: [
                A->a,
                A->b,
            ]
        },
        {
            nonterminalId: S,
            sets: [
                S->acd,
                S->bcd
            ]
        }
    ]
    
*/
typedef struct {
    /* 非终结符在前，终结符在后 */
    char * data;
    uint32_t nonTerminalNums;
    uint32_t terminalNums;
} CharacterSet;

/* 存取终结符或非终结符在数组中的索引 */
typedef struct {
    uint32_t nonterminalId;
    uint32_t * sets[PRODUCTION_NUMS]; 
} Production;

/* 文法数据结构 */
typedef struct {
    /* 包含终结符以及非终结符， */
    CharacterSet* charSets;
    Production* productions;
    size_t startSymbol;
} GrammerData;


void ConstructGrammer() {

}

void Input() {

}

void EliminatingLeftRecursion() {

}

void SyntaxAnalyzer(const char * fileName) {

}